package com.bingo.transaction;

import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class MQUtils {

    public static final Map<String, Object> executeLocalResult = new ConcurrentHashMap<>();

    public static Object get(String key) {
        if (StringUtils.isEmpty(key)) {
            return null;
        }
        if (!ObjectUtils.isEmpty(executeLocalResult.get(key))) {
            Object o = executeLocalResult.get(key);
            executeLocalResult.remove(key);
            return o;
        }
        return null;
    }

    public static void put(String key, Object o) {
        if (!ObjectUtils.isEmpty(key) && !ObjectUtils.isEmpty(o)) {
            executeLocalResult.put(key, o);
        }
    }
}
